import retrieve 
import jieba
# retriever = retrieve.Retriever()
# docs = retriever.Parse()
# retrieve.WritePure("./pure.txt",docs)

class Index:
    def __init__(self):
        self.forward_index = []
        self.invert_index = []
        
    def Build_forward_index(self,doc):
        self.forward_index.append(doc)
    def Build_invert_index(self,doc):

    def Build(self,path):
        with open(path,'r',encoding='utf-8') as f:
            for line in f:
                # title\3body\3url\n
                line.rstrip('\n')
                parts = line.split('\3')
                if len(parts)==3:
                    doc = retrieve.Document(parts[0],parts[1],parts[2])
                    self.Build_forward_index(doc)
                    self.Build_invert_index(doc)




# with open("pure.txt","r",encoding='utf8') as f:
# 	for line in f:
# 		line.rstrip('\n')
# 		parts = line.split("\3")
# 		if len(parts) == 3:
# 			for part in parts:
# 				print(part)
                
# str = "title\3body\3url\nhello\3this is \3url222\n"
# with open("test.txt","w",encoding='utf-8') as f2:
# 	f2.write(str)
    
# with open('test.txt','r',encoding='utf-8') as f3:
# 	for line in f3:
# 		line.rstrip('\n')
# 		parts = line.split("\3")
# 		print(len(parts))
# 		for part in parts:
# 				print(part)
